<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <!--<link rel="stylesheet" type="text/css" href="/easyui/themes/metro/easyui.css"/>-->
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="/topjui/css/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="/topjui/themes/default/topjui.bluelight.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="/static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="/static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <link type="text/css" href="/topjui/css/myui.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/static/plugins/raty/jquery.raty.css">
    <script type="text/javascript" src="/static/public/js/topjui.config.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="/static/plugins/layui/layui.js" charset="utf-8"></script>
    <script src="/easyui/jquery.min.js"></script>
    <script src="/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/topjui/js/sysutils.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=lqVkw7DAWGt8CA9NAzxGWrQq"></script>
    <script src="/static/plugins/raty/jquery.raty.js"></script>
</head>

<body>

<table id="rowgrid" class="topjui-datagrid"></table>

<script type="text/javascript" charset="utf-8" th:inline="none">
    var listgrid;
    $(function(){
        listgrid = $('#rowgrid').datagrid({
            url:"/report/taskList",
            method:'get',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : false,
            nowrap : false,
            columns:[[
                {
                    field:'routername',
                    title:'巡视单位',
                    width:60
                }, {
                    field:'allsum',
                    title:'派单总次数',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'total',
                    title:'任务总分',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'donesum',
                    title:'已完成的派单数',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'undosum',
                    title:'未完成的派单数',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'warnningsum',
                    title:'延时完成的项目数',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'score',
                    title:'完成任务总分',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }
            ]],
            toolbar:[{
                text:'查询',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    list_search();
                }
            },'-', {
                text:'导出',
                iconCls : 'fa fa-file-excel-o',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    routerlist_excel();
                }
            },'-', {
                text:'刷新',
                iconCls : 'fa fa-refresh',
                btnCls: 'topjui-btn-green',
                handler : function() {
                    listgrid.datagrid('reload');
                }
            }],
            onDblClickRow :function(rowIndex,rowData){
                list_editMapFun(rowData.id);
            }
        });
    });

    function list_search(){
        $('<div/>').dialog({
            href : "/report/map",
            width : 390,
            height : 180,
            modal : true,
            title : '查询',
            buttons : [{
                text : '查询',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    var d = $(this).closest('.window-body');
                    var param = form2Json("search_form");
                    $('#search_form').form('submit', {
                        url : '/report/routerTj',
                        onSubmit:function(){
                            return true;
                        },
                        success : function(result) {
                            try {
                                var r = $.parseJSON(result);
                                listgrid.datagrid({
                                    url:'/report/routerTj',
                                    pagination : false,
                                    idField : 'id',
                                    queryParams: param,　　//关键之处
                                    data:r
                                });
                                d.dialog('destroy');

                            } catch (e) {
                                $.messager.alert('提示', result);
                            }
                        }
                    });
                }
            }],
            onClose : function() {
                $(this).dialog('destroy');
            },
            onLoad : function() {
                //日期样式
                $('#form-taskdate').datebox({
                    required: true,
                    formatter:ww4,
                    parser:w4
                });
                $(".combo-text").removeAttr("style");
                $(".combo-text").attr("style", "width:250px;height:24px;line-height:24px");
                $(".combo-text").addClass("selectp");
                $(".combo-arrow").attr("style", "margin-left: -20px;margin-top: 3px;background-color:rgba(0,0,0,0)");
                $(".combo-panel").attr("style", "margin-top:0px;");
            }
        });
    }

    function routerlist_excel(){
        $('<div/>').dialog({
            href : "/report/map",
            width : 390,
            height : 180,
            modal : true,
            title : '数据导出',
            buttons : [{
                text : '下载',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    var d = $(this).closest('.window-body');
                    var param = form2Json("search_form");
                    download('/report/routerTjExcel',param,'post');
                    d.dialog('destroy');
                }
            }],
            onClose : function() {
                $(this).dialog('destroy');
            },
            onLoad : function() {
                //日期样式
                $('#form-taskdate').datebox({
                    required: true,
                    formatter:ww4,
                    parser:w4
                });
                $(".combo-text").removeAttr("style");
                $(".combo-text").attr("style", "width:250px;height:24px;line-height:24px");
                $(".combo-text").addClass("selectp");
                $(".combo-arrow").attr("style", "margin-left: -20px;margin-top: 3px;background-color:rgba(0,0,0,0)");
                $(".combo-panel").attr("style", "margin-top:0px;");
            }
        });
    }

    function ww4(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        //return  y+'-'+(m<10?('0'+m):m);
        return  y+(m<10?('0'+m):""+m);
    }
    function w4(s){
        if (!s) {
            return new Date();
        }else{
            var y = s.substring(0,4);
            var m = s.substring(4,7);
            return new Date(y,m-1);
        }

    }

</script>

</body>
</html>